package Function.ItemUse;

import FCRendering.FCRConstants;
import VWorldGameStudio.FCBattleOrder;
import VWorldGameStudio.FCMonster;
import VWorldGameStudio.FCPlayerInfo;
import VWorldGameStudio.FCTank;

import static FCRendering.FCRMaster.*;

public class ToolTankCard extends AItemUse {


    @Override
    public ItemUseResult directUse() {
        if(fcv.isBattle()){
            fcv.getMessage().add("不能在战斗中使用");
            fcv.showMessage();
            return new ItemUseResult().useless();
        }
        fcv.closeAllShowWindw();
        FCTank tank = tankLib.getTankOfID(useItem.getRelateTankId(), gameSave.HOST_UID);
        if (tank != null) {
            String oldtankName = player1.getPlayertank1();
            String oldTankHostId = player1.getPlayertankHostId();
            tank.setVisable(1);
            gameSave.useTankOfPlayerId(player1, oldtankName, oldTankHostId);//先下车
            gameSave.useTankOfPlayerId(player1, tank.getName(), tank.getHostId());//再上车
            gameSave.useTankOfPlayerId(player1, tank.getName(), tank.getHostId());//再下车
            gameSave.useTankOfPlayerId(player1, oldtankName, oldTankHostId);//上回旧车
            fcv.getMessage().add("眼前出现了一俩坦克!");
            fcv.showMessage();

            useAfter();
        }
        return null;
    }

    @Override
    public ItemUseResult useInMapTarget(int x, int y) {
        return directUse();
    }

    @Override
    public ItemUseResult useForMonsterTarget(FCBattleOrder battleOrder, FCMonster m) {
        return directUse();
    }

    @Override
    public ItemUseResult useForPlayerTarget(FCPlayerInfo p) {
        return directUse();
    }

    @Override
    public ItemUseResult useForTankTarget(FCTank t) {
        return directUse();
    }
}
